<template>
    <div>
        this is terationDetail

      {{this.iterationData.test}}
      <el-tabs tab-position="top" @tab-click="tabChange">
        <el-tab-pane label="需求" name="demand">
          <demandModule :demand="iterationData.demand" :iterationId="iterationData.id" :employees="employees"></demandModule>
        </el-tab-pane>
        <el-tab-pane label="研发" name="develop">研发{{iterationData.develop}}</el-tab-pane>
        <el-tab-pane label="测试" name ='test'>
          <div class="timepick">
            <div style="float:left;width:49%;border:1px ">
              <!-- v-if="!scope.row.test.editable"-->
              <el-button type="primary"  size="mini"
                         @click="!editable ?edit(iterationData.test,1):updateTestInfo(iterationData)">{{!editable ?'修改':'确认'}}
              </el-button>
              <!--<el-button type="primary" v-if="scope.row.test.editable" size="mini"
                         @click="updateTestInfo(scope.row)">确认
              </el-button>-->
              <div class="textstyle">测试人员：<span>
                   <!-- <el-tag :key="testperson" v-for="testperson in scope.row.test.tester" :closable="scope.row.test.editable" :disable-transitions="false" @close="deleteExector(testperson,scope.row.test.tester)">{{testperson}}</el-tag>
                    <input class='input_size' v-show="scope.row.test.editable" v-model="scope.row.test.tester.toString()" size="mini"  />-->

                    <ecectorShow :exectors="iterationData.test.workers" :editable="editable"
                                 :employees="employees"></ecectorShow>
                  </span>
              </div>
              <datePick class="textstyle" name="测试时间" @dateChangeHandle="getChildDate($event,iterationData.test)" :date1="iterationData.test.scheduleTimeFrom" :date2="iterationData.test.scheduleTimeTo" :editable="editable"></datePick>
              <div class="textstyle">
                测试进度：<span v-show="!editable">{{iterationData.test.progress }}%</span>
                <input class='input_size' v-show="editable" v-model="iterationData.test.progress"
                       size="mini"/>
              </div>
              <div class="textstyle">
                实际测试时间：
                <el-date-picker
                  v-model="iterationData.test.practiceTimeFrom"
                  type="date"
                  disabled
                  value-format="yyyy-MM-dd HH:mm:ss"
                  size="mini"
                  placeholder="选择日期">
                </el-date-picker>
                至
                <el-date-picker
                  v-model="iterationData.test.practiceTimeTo"
                  type="date"
                  value-format="yyyy-MM-dd HH:mm:ss"
                  disabled
                  size="mini"
                  placeholder="选择日期">
                </el-date-picker>
              </div>
              <div class="textstyle">测试用例：<span v-show="!editable">{{iterationData.test.testCaseURL  }}</span>
                <input class='input_size' v-show="editable" v-model="iterationData.test.testCaseURL"
                       size="mini"/></div>
              <div class="textstyle">冒烟用例：<span v-show="!editable">{{iterationData.test.quickTestCaseURL  }}</span>
                <input class='input_size' v-show="editable" v-model="iterationData.test.quickTestCaseURL"
                       size="mini"/></div>
              <div class="textstyle">风险点：<span v-show="!editable">{{iterationData.test.riskPoint  }}</span>
                <input     type='textarea' autosize class='input_size' v-show="editable" v-model="iterationData.test.riskPoint"
                           size="mini"/></div>
            </div>
            <tasksModule :tasks="iterationData.test.tasks" :employees="employees" :ownNo="iterationData.test.testNo"></tasksModule>
          </div>

        </el-tab-pane>
        <el-tab-pane label="缺陷" name="bug">

          <bugModule :iterantionInfo="iterationData" :employees="employees"></bugModule>
        </el-tab-pane>
      </el-tabs>





    </div>
</template>

<script>
  import {getInterationDetail ,getemployees,saveTestInfo} from  '../../../api/testmanager'
  import bugModule from './bugManager'
  import vue from 'vue'
  import ecectorShow from './ecectorShow'
  import tasksModule from './taskManager'
  import datePick from './datePick'
  import demandModule from './demandManager'
    export default {
        name: "IterationDetail",
      data(){
          return{
            iterationData:{},
            employees:[],
            editable:false,
          }
      },
      methods:{
        tabChange(event){
          //console.log('===')
          // console.log(event)
        },
        getChildDate(event, test){
          /*date1="scope.row.test.scheduleTimeFrom" :date2="scope.row.test.scheduleTimeT
          console.log(data);
          console.log(event);*/
          test.scheduleTimeFrom=event[0]
          test.scheduleTimeTo=event[1]
        },
          getIterationData(id){
            getInterationDetail(id)
              .then(res=>{
                this.iterationData = res.data
              }).catch(err=>{
              this.$alert(err.data, 'error')
            })

          },
        getEmplorers() {
          getemployees()
            .then(res => {
              this.employees = res.data

            }).catch(err => {
            this.$alert(err.data, 'error')
          })


          return this.employees

        },
        edit(value2, index) {
            this.editable = true
         // vue.set(value2, 'editable', true)
        },
        updateTestInfo(row) {
       //   vue.delete(row.test, 'editable')
          saveTestInfo(row.id,row.test)
            .then(res => {

            }).catch(err => {
            this.$alert(err.data, 'error')
          })
          this.editable = false
        },
      },
      created(){

          this.getIterationData(this.$route.params.id)

      },
      mounted(){
        this.getEmplorers();
      },
      components: {
        ecectorShow,
        tasksModule,
        datePick,
        bugModule,
        demandModule,
      }


    }
</script>

<style scoped>

</style>
